/** * b */

<template>
  <div>
    <h2>测试mock拦截请求表格数据</h2>
    <FCButton
      value="获取表格最新数据"
      @click="getTableData"
    />
    <a-table
      :loading="loading"
      :columns="fields"
      rowKey="id"
      :data-source="dataSource"
    >
    </a-table>
  </div>
</template>

<script>
import FCTable from '@/vendors/fc-ui/src/table/FCTable.vue'
import FCButton from '@/vendors/fc-ui/src/controls/FCButton.vue'
import axios from 'axios'

export default {
  name: 'pageB',
  components: {
    FCTable,
    FCButton,
  },
  data() {
    return {
      apiUrl: '/test/getUserList',
      fields: [
        {
          title: '姓名',
          dataIndex: 'name',
        },
        {
          title: '联系电话',
          dataIndex: 'phone',
        },
        {
          title: '地址',
          dataIndex: 'addr',
        },
        {
          title: '等级',
          dataIndex: 'level',
        },
      ],
      dataSource: [],
      loading: false,
    }
  },
  mounted() {
    // this.getTableData();
  },
  methods: {
    async getTableData() {
      this.loading = true
      const res = await axios.post(this.apiUrl)
      console.log('获取的表格数据res:', res)
      this.loading = false
      this.dataSource = res?.data?.data?.data
      console.log('>>> this.dataSource:', this.dataSource)
    },
  },
}
</script>

<style></style>
